{template 'weheader'}
{if $reside}<script src="{MODULE_URL}template/weui/js/city-picker.min.js"></script>{/if}
{if $isloc}<script type="text/javascript" src="{TEMPLATE_WEUI}js/QQgetLocation.js"></script>{/if}
<script type="text/javascript" src="{TEMPLATE_WEUI}js/scrolling.min.js"></script>
<style>
body{background-color:#f0f0f0;}

.weui_textarea_counter span {font-size:12px;}
.weui_label span{color: #E64340;}
.weui-popup-container{z-index:9999;}
.weui_cell_select .weui_cell_td {padding-left: 1em;}
.weui_cell_select .weui_cell_hd .weui_select {line-height:45px;padding:0 25px 0 5px;color: #555;}

.weui_extra_area {z-index:0;}
.weui_cells{margin:0 auto;margin-top:0;}
.record .weui_cells:first-child {margin-top:30px;}
.record .weui_cells {margin:0;}
.record img{width:1.2rem;height:1.2rem;}
.m-img {background-position: top center;padding-bottom: 0;}
.m-img img{width:100%;height:auto;}
.m-masker {background-color: rgba(0, 0, 0, 0);position: relative;}

#allmap{width:100%;height:200px;display:block}

.weui_cells:before{top:0;border-top:0px solid #d9d9d9;}
.weui_cells:after,.weui_cells:before{height:0px;}
.weui_cells:after{bottom:0;border-bottom:0px solid #d9d9d9;}
.submit{border-radius:25px;border:0;}
.submit:after{border:0px solid rgba(0,0,0,.2);}
.weui_btn_area{margin:10px 15px 20px}
.weui_input{border:1px solid #ddd;line-height:100%;height:45px;border-radius:2px;text-indent:10px;}

.back_up{right: 0px; bottom: 0px;}
</style>
	<div class="weui-header f-black" style="background-color:#fff;"> 
		<div class="weui-header-left">
			<a class="f-black" href="javascript:history.go(-1)">
			<svg class="icon" aria-hidden="true">
				<use xlink:href="#icon-home"></use>
			</svg>
			</a></div>
		<h1 class="weui-header-title f16 f-black" style="line-height:45px;">{$activity['title']}</h1>
		<div class="weui-header-right">
			<a class="f-black" href="{php echo $this->createMobileUrl('mydayu_form', array('weid' => $_W['uniacid'], 'id' => $reid))}">
				<svg class="icon" aria-hidden="true">
					<use xlink:href="#icon-list"></use>
				</svg>
			</a>
		</div> 
	</div>
	<div class="m-box" style="margin:0;">
		<div class="m-img"><img src="{$activity['thumb']}"></div>
		<div class="m-masker"> 
			<div class="weui_media_box weui_media_text" style="position: absolute;bottom:0px;width:90%;">
			</div>
		</div> 
	</div>
<form action="{php echo $this->createMobileUrl('dayu_form', array('weid' => $_W['uniacid'], 'id' => $reid))}" class="" enctype="multipart/form-data" method="POST" id="form">
<input type="hidden" name="repeat" value="<?php echo md5(sha1(time())); ?>">

<div class="weui_cells weui_cells_form" style="margin-top:-10px;">
    <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" id="member" name="member" type="text" value="{$member['realname']}" placeholder="请输入{$activity['member']}">
        </div>
    </div>
</div>
<div class="weui_cells weui_cells_form">
    <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary ">
            <input class="weui_input" id="mobile" name="mobile" type="tel" pattern="[0-9]*" value="{$member['mobile']}" placeholder="请输入{$activity['phone']}">
        </div>
    </div>
</div>
	{if $activity['smsid']!=0}
<div class="weui_cells weui_cells_form">
    <div class="weui_cell">
		<input type="hidden" id="htel">
		<input type="hidden" id="hsms">
        <div class="weui_cell_hd"><label class="weui_label">验证码<span>*</span></label></div>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" id="sms" name="sms" type="tel" placeholder="请输入验证码">
        </div>
		<div class="weui_cell_ft" style="margin:0;">
        <input type="button" id="sendsms" class="weui_btn weui_btn_mini weui_btn_primary" value="获取验证码">
		</div>
    </div>
</div>
	{/if}
	{if !empty($linkage)}
<div class="weui_cells weui_cells_form">
	<div class="weui_cell weui_cell_select weui_select_after">
		<div class="weui_cell_hd"><label for="" class="weui_label">{$la['l1']}</label></div>
		<div class="weui_cell_bd weui_cell_primary">
			<select class="weui_select" name="linkage1" onchange="fetchgetjs(this)" id="linkage1">
				<option value="" >请选择{$la['l1']}</option>
			{loop $linkage $val}
				<option value="{$val['id']}">{$val['title']}</option>
			{/loop}
			</select>
		</div>
	</div>
</div>
<div class="weui_cells weui_cells_form">
	<div class="weui_cell weui_cell_select weui_select_after">
		<div class="weui_cell_hd"><label for="" class="weui_label">{$la['l2']}</label></div>
		<div class="weui_cell_bd weui_cell_primary">
			<select class="weui_select" name="linkage2" id="linkage2" onchange="showjishi(this)">
				<option value="" >请选择</option>
			</select>
		</div>
	</div>
</div>
	{/if}
	{loop $ds $fields}
	{if $fields['type'] == 'text'}
<div class="weui_cells weui_cells_form">
	<div class="weui_cell">
		<div class="weui_cell_bd weui_cell_primary">
		{if $fields['bind'] == 'birth'}
			<input class="weui_input" name="field_{$fields['refid']}_{$fields['bind']}" type="text" value="{$profile['birthyear']}-{$profile['birthmonth']}-{$profile['birthday']}" placeholder="{$fields['tixing']}" {if $fields['essential']}required{/if}>
		{else}
			<input class="weui_input" name="field_{$fields['refid']}_{$fields['bind']}" type="text" value="{$fields['default']}" placeholder="{$fields['tixing']}" {if $fields['only']}id="n_{$fields['refid']}" onblur="check(this,'{$fields['refid']}')" data="{$fields['title']}"{/if} {if $fields['essential']}required{/if}>
		{/if}
		</div>
		{if $fields['loc']}
		<div class="weui_cell_ft">
			<a href="javascript:void(0);" onclick="getLocation(this,'field_{$fields['refid']}_{$fields['bind']}');" class="f18">
				<svg class="icon" aria-hidden="true">
					<use xlink:href="#icon-Geo-fence"></use>
				</svg>
			</a>
		</div>
		{else}
		<div class="weui_cell_ft"></div>
		{/if}
	</div>
</div>
	{/if}
		
		{if $fields['type'] == 'email'}
<div class="weui_cells weui_cells_form">
	<div class="weui_cell">
		<div class="weui_cell_bd weui_cell_primary">
			<input class="weui_input" type="text" name="field_{$fields['refid']}_{$fields['bind']}" value="{$fields['default']}" placeholder="{$fields['tixing']}" {if $fields['essential']}required{/if}>
		</div>
	</div>
</div>
		{/if}
				
		{if $fields['type'] == 'number'}
<div class="weui_cells weui_cells_form">
	<div class="weui_cell">
		<div class="weui_cell_bd weui_cell_primary">
			<input class="weui_input" type="tel" name="field_{$fields['refid']}_{$fields['bind']}" value="{$fields['default']}" pattern="[0-9]*" placeholder="{$fields['tixing']}">
		</div>
	</div>
</div>
		{/if}
				
		{if $fields['type'] == 'textarea'}
<div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_bd weui_cell_primary">
			<textarea class="weui_textarea" name="field_{$fields['refid']}_{$fields['bind']}" rows="3" placeholder="{$fields['tixing']}">{$fields['default']}</textarea>
                <div class="weui_textarea_counter"><span id='textarea_num'>限200字</span></div>
            </div>
        </div>
</div>
          <script>
$(function(){
	$(".weui_textarea").on("input paste" , function(){
				var num_left=$(this).val().length;
				if((200-num_left)<0){
					$("#textarea_num").text("超出"+(num_left-200)+"字");
					$("#textarea_num").css("color","#E44443");
				}else{
					$("#textarea_num").text((num_left)+"字");
					$("#textarea_num").css("color","#999999");
				}
			});

})
</script> 
		{/if}
				
		{if $fields['type'] == 'radio'}
		<div class="weui_cells_title">{$fields['title']}{if $fields['essential']}<span class="f-red">*</span>{/if}</div>
		<div class="weui_cells weui_cells_radio">
			{php $i=1;}
			{loop $fields['options'] $v}
			<label class="weui_cell weui_check_label" for="r{$fields['refid']}{$i}">
				<div class="weui_cell_bd weui_cell_primary"><p>{$v}</p></div>
				<div class="weui_cell_ft">
					<input type="radio" class="weui_check" name="field_{$fields['refid']}_{$fields['bind']}" id="r{$fields['refid']}{$i}" value="{$v}" {if $i==1}checked="checked"{/if}>
					<span class="weui_icon_checked"></span>
				</div>
			</label>
				{php $i++;}
			{/loop}
		</div>
		{/if}
				
		
		{if $fields['type'] == 'checkbox'}
		<div class="weui_cells_title">{$fields['title']}{if $fields['essential']}<span class="f-red">*</span>{/if}</div>
		<div class="weui_cells weui_cells_checkbox">
			{php $i=1;}
			{loop $fields['options'] $v}
			<label class="weui_cell weui_check_label" for="c{$fields['refid']}{$i}">
				<div class="weui_cell_hd">
					<input type="checkbox" class="weui_check" name="field_{$fields['refid']}_{$fields['bind']}[]" id="c{$fields['refid']}{$i}" value="{$v}">
					<i class="weui_icon_checked"></i>
				</div>
				<div class="weui_cell_bd weui_cell_primary"><p>{$v}</p></div>
			</label>
				{php $i++;}
			{/loop}
		</div>
		{/if}
						
		{if $fields['type'] == 'select'}
		<div class="weui_cell weui_cell_select weui_select_after">
			<div class="weui_cell_hd">{$fields['title']}{if $fields['essential']}<span>*</span>{/if}</div>
			<div class="weui_cell_bd weui_cell_primary">
				<select class="weui_select" name="field_{$fields['refid']}_{$fields['bind']}">
				{loop $fields['options'] $v}
					<option value="{$v}" {if $v == $fields['default']} selected="selected"{/if}>{$v}</option>
				{/loop}
				</select>
			</div>
		</div>
		{/if}

		{if $fields['type'] == 'image'}
<div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_bd weui_cell_primary">
                <div class="weui_uploader">
                    <div class="weui_uploader_hd weui_cell">
                        <div class="weui_cell_bd weui_cell_primary">{$fields['title']}{if $fields['essential']}<span>*</span>{/if}</div>
                        <div class="weui_cell_ft"></div>
                    </div>
                    <div class="weui_uploader_bd">
                        <ul class="weui_uploader_files">   
                            <input type="hidden" name="field_{$fields['refid']}_{$fields['bind']}" accept="image/*" capture="camera" value="" />                        
                            <image class="weui_uploader_file weui_uploader_status" onclick="show(this,'show{$fields['refid']}')" id="show{$fields['refid']}" src="{php echo tomedia($fields['image'])}" />
                        </ul>
                        <div class="weui_uploader_input_wrp" data="field_{$fields['refid']}_{$fields['bind']}" onclick="upimg(this,{$fields['refid']})" id="{$fields['refid']}">
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
		{/if}
		
		{if $fields['type'] == 'calendar'}
<div class="weui_cells weui_cells_form">
		<div class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary">
				{if $fields['bind'] == 'birth'}
					<input class="weui_input" name="field_{$fields['refid']}_{$fields['bind']}" type="text" value="{$profile['birthyear']}-{$profile['birthmonth']}-{$profile['birthday']}" placeholder="{$fields['tixing']}" id="{$fields['refid']}">
		<script>
			$("#{$fields['refid']}").datetimePicker({title:"选择{$fields['title']}",m:1});
		</script>
				{else}
					<input class="weui_input" name="field_{$fields['refid']}_{$fields['bind']}" type="text" value="" placeholder="{$fields['tixing']}" id="{$fields['refid']}">
		<script>
			$("#{$fields['refid']}").datetimePicker({title:"选择{$fields['title']}",m:1});
		</script>
				{/if}
				</div>
		</div>
</div>
		{/if}
		
		{if $fields['type'] == 'range'}
<div class="weui_cells weui_cells_form">
		<div class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="field_{$fields['refid']}_{$fields['bind']}" value="" placeholder="{$fields['tixing']}" id="{$fields['refid']}" />
				</div>              
		</div>
</div>
    <script>
      $("#{$fields['refid']}").datetimePicker();
    </script>
		{/if}
		
		{if $fields['type'] == 'reside'}
<div class="weui_cells weui_cells_form">
		<div class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary">
					<input class="weui_input" type="text" name="field_{$fields['refid']}_{$fields['bind']}" value="" placeholder="{$fields['tixing']}" id="{$fields['refid']}"/>
				</div>
		</div>
</div>
    <script>
	$("#{$fields['refid']}").cityPicker({
		title: "{$fields['title']}"
	});
    </script>
		{/if}
		
				{/loop}
	{if $activity['plural']==1}
<div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_bd weui_cell_primary">
                <div class="weui_uploader">
                    <div class="weui_uploader_hd weui_cell">
                        <div class="weui_cell_bd weui_cell_primary">{$activity['pluraltit']}</div>
                        <div class="weui_cell_ft">最多9张</div>
                    </div>
                    <div class="weui_uploader_bd">
                        <ul class="weui_uploader_files" id="pub-pics">   
                        </ul>
                        <div class="weui_uploader_input_wrp">
                                <div id="chooseImage" style="width: 100%;height: 100%;" class="weui_uploader_input"></div> 
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
<script type="text/javascript">
	var images = {
		localId: [],
		serverId: []
	};
	document.querySelector('#chooseImage').onclick = function () {
		wx.chooseImage({
			success: function (res) {
				images.localId = res.localIds;
	        
				if (images.localId.length == 0) {
					return;
				}
				var m = 0, length = images.localId.length;
	        
	        
				images.serverId = [];
				function upload() {
					wx.uploadImage({
						localId: images.localId[m],
						success: function (res) {
							m++;
							images.serverId.push(res.serverId);
							var url = "{php echo $this->createMobileUrl('uploads',array('type'=>'image'));}&serverId=" + res.serverId + "&localId=" + m;
							$.post(url, function(dat){
								var dat = eval("("+dat+")");
								$upload = $( '#pub-pics' );
								$li = $('<li onclick="var delimg=$(this);$.confirm(\'您确定要删除该图片吗?\', \'确认删除?\', function() {delimg.remove();},function(){$.toast(\'取消操作\', \'cancel\');});" class="weui_uploader_file weui_uploader_status" style="background-image:url('+dat.imgurl+')"><input type="hidden" name="thumb[]" value="'+dat.path+'"/><div class="weui_uploader_status_content"><i class="weui_icon_cancel"></i></div></li>')
								$upload.append($li);
							});
							if (m < length) {
								upload();
							}
						},
						fail: function (res) {
							//上传失败
							alert(JSON.stringify(res));
						}
					});
				}
				upload();	        
			}
		});
	};
</script>
{/if}
{if $activity['isvoice']==1}
<div class="weui_cells weui_cells_form">
	<div class="weui_cells_title tright"><span class="left">{$activity['voice']}{if $activity['ivoice']==1}<span class="f-red">*</span>{/if}</span><span class="f12">{$activity['voicedec']}</span></div>	
	<div class="weui_cell">
		<div class="weui_cell_hd">		
			<div class="record-start-btn iconfont f35 f-white left" id="record-start">&#xe62a;</div>
			<div class="record-stop-btn iconfont f35 f-white left" id="record-stop">&#xe62a;</div>
			<div class="record-time f-orange f12 right"></div>
			<div class="record-prompt f-orange f12 middle right"><span class="block f-blue">蓝色开始录音</span><span class="block f-red">红色停止录音</span></div>
			<input type="hidden" name="voice" id="showvoice" value="" />
		</div>
		<div class="weui_cell_bd weui_cell_primary">
			<div class="send-control right">
				<div class="send-record-btn" id="send-record-btn">上传录音</div>
				<div class="send-success weui_btn_disabled" id="send-success" style="display:none;">上传成功</div>
			</div>
		</div>
	</div>
</div>
<script>
    var upload_url='{php echo $_W['siteroot'].'app/'.$this->createMobileUrl('uploadvoice',array());}';
    var getprefop_url='{php echo $_W['siteroot'].'app/'.$this->createMobileUrl('getprefop',array());}';
          var btn = document.getElementById('send-record-btn');
		  
  //        btn.onclick = function(){
		var localId = null;
		var serverId = null;
        var timer = null;
        var timerTime = 0;
		
		$(".record-start-btn").click(function () {
            $(".record-start-btn").hide();
            $(".record-stop-btn").show();
            $(".record-prompt").hide();
            timerTime = 0;
            $(".record-time").text("");
            timer = setInterval(function () {
                timerTime++;
                $(".record-time").text("时长:" + timerTime + "秒");
				if (timerTime >58) {
					wx.stopRecord({
						success: function (res) {
							localId = res.localId;
							recordComplete();
						},
						fail: function (res) {
							alert(JSON.stringify(res));
						}
					});
				}
            }, 1000);
//			wx.startRecord();
			wx.startRecord({
				cancel: function () {
					alert('您拒绝了授权录音');
				}
			});
            wx.onVoiceRecordEnd({
                // 录音时间超过一分钟没有停止的时候会执行 complete 回调
                complete: function (res) {
                    localId = res.localId;
                    recordComplete();
					alert('录音时间已超过一分钟');
                }
            });
        });
        $(".record-stop-btn").mouseup(function () {
            wx.stopRecord({
                success: function (res) {
                    localId = res.localId;
                    recordComplete();
//						document.getElementById('showvoice').value = localId;
					$('#send-record-btn').css('display','');
					$('#send-success').css('display','none');
                },
				fail: function (res) {
					alert(JSON.stringify(res));
				}
            });
        });
        function recordComplete() {
            wx.playVoice({
                localId: localId // 需要播放的音频的本地ID，由stopRecord接口获得
            });
            clearInterval(timer);
            $(".record-stop-btn").hide();
            $(".record-start-btn").show();
            $(".send-control").show();
        }

		$(".send-record-btn").click(function () {
            if (localId == null)
                return;
            wx.uploadVoice({
                localId: localId, // 需要上传的音频的本地ID，由stopRecord接口获得
                serverId: serverId,
                isShowProgressTips: 1, // 默认为1，显示进度提示
                success: function (res) {
				
                $.ajax({
                  type: 'POST',
                  url: upload_url,
                  data:{serverId:res.serverId},
                  timeout: 15000,
                  success: function(res){
                    if (/^qiniu-persistentId.*$/.test(res)) {
                        var tmp=res.split(':');
                        setInterval(function () {
                            $.ajax({
                                type: 'POST',
                                url: getprefop_url,
                                data:{persistentId:tmp[1]},
                                success: function(res) {
                                    if (res == 1) location.href =tmp[2];
                                },
                                fail: function(err) {
                                    alert(JSON.stringify(err));
                                }
                            });
                        },1000);
                    }else{
                    }
                  },
                  fail: function(err) {
                      alert(JSON.stringify(err));
                  }
                });
//				alert('上传语音成功，serverId 为' + res.serverId);
					serverId = res.serverId; // 返回音频的服务器端ID
					document.getElementById('showvoice').value = "dayu_form_{$_W['uniacid']}_"+serverId+".mp3";
					$('#send-record-btn').css('display','none');
					$('#send-success').css('display','');
                },
				fail:function() {
					alert(JSON.stringify(res));
				}
            });
		});
</script>
{/if}
	
<div class="weui_cells weui_cells_form">
    <div class="weui_btn_area row" style="background-color:#fff;">
	{if !empty($activity['agreement'])}
		<div class="weui_cells_checkbox">
			<label class="weui_cell weui_check_label" for="agreement">
				<div class="weui_cell_hd">
					<input type="checkbox" name="agreement" class="weui_check" id="agreement">
					<i class="weui_icon_checked"></i>
				</div>
				<div class="weui_cell_bd weui_cell_primary f14">
					<p>我已阅读并同意<a href="javascript:;" class="open-popup" data-target="#popup">《{$activity['agreement']}》</a></p>
				</div>
			</label>
		</div>
	{/if}
		{if !empty($par['var1'])}<input type="hidden" name="{$par['var1']}" value="{$_GPC[$par['var1']]}">{/if}
		{if !empty($par['var2'])}<input type="hidden" name="{$par['var2']}" value="{$_GPC[$par['var2']]}">{/if}
		{if !empty($par['var3'])}<input type="hidden" name="{$par['var3']}" value="{$_GPC[$par['var3']]}">{/if}
		<input type="hidden" name="token" value="{$_W['token']}" />
        <button class="weui_btn weui_btn_primary submit" name="submit" type="submit" id="showTool">{$submitname}</button>
    </div>
</div>
</form>
	<div class="weui-weixin" style="margin-top:20px;">
		<div class="weui-weixin-ui">
			<div class="weui-weixin-page">
				<div class="weui-weixin-content f13">
				{php echo htmlspecialchars_decode($activity['content'])}
				</div>   
			</div>
		</div>
	</div>
	<div class="back_up" style="width:100%;height:60px;">
		<div class="weui_cells" style="width:100%;background-color:rgba(255,255,255,.9);">
			<div class="weui_cell">
				<div class="weui_cell_hd">
					<a href="tel:{$par['tel']}" class="weui_label">
						<svg class="icon f35" aria-hidden="true">
							<use xlink:href="#icon-phone"></use>
						</svg>
					</a>
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<span class="weui_btn weui_btn_primary submit">立 即 预 约</span>
				</div>
			</div>
		</div>   
	</div>
{if $activity['smsid']!=0}
<script type="text/javascript">
		var wait=60;  
		function time(o) {
			if (wait == 0) {
				o.removeAttribute("disabled");
				o.value="获取验证码";
				wait = 60;
			} else {
				o.setAttribute("disabled", true);
				o.value="重新发送(" + wait + ")";
				wait--;  
				setTimeout(function() {
					time(o)
				},
            1000)
			}
		}
	$("#sendsms").bind("click",function(){
		var checktel = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
			if($.trim($(':input[name="mobile"]').val())=='' || !checktel.test($.trim($('input[name="mobile"]').val()))){
				$('#mobile').attr("readonly",false);
				$.toast("请输入正确的手机号码", "cancel");
				return false;
			}else{
				$('#mobile').attr('readonly',true);
				var submitData = {};
				$.post("{php echo murl('entry', array('do' => 'SendSms', 'id' => $activity['smsid'], 'm' => 'dayu_sms'), true, true)}"+"&mobile="+$("#mobile").val(), submitData,function(data){
						$.toast(data.message.msg, "success");
					if(data.message.state == 1) {
						$("#htel").val(data.message.mobile);
						$("#hsms").val(data.message.yzm);
						$.toast(data.message.msg, "success");
					}else{
						$.toast(data.message.msg, "cancel");
					}
				},"json");
				time(this);
			}
	});
</script>
{/if}
<script type="text/javascript">
window.addEventListener('scroll',function(){
    var _scrollTop = document.body.scrollTop;
    var $backUp = document.querySelector('.back_up');
    if(_scrollTop > 380){
        $backUp.classList.add('show');
    }else{
        $backUp.classList.remove('show');
    }
    if(_scrollTop > 0){
    }
},false);
document.querySelector('.back_up').addEventListener('click',function(){
    scrolling();
},false);
	function check(obj,refid){
		var content = $("#n_"+refid).val();
		$.getJSON('{php echo $this->createMobileUrl('checkonly')}', {'reid' : '{$reid}', 'refid' : refid, 'content' : content, 'title' : obj.getAttribute("data")}, function(s){
			if (s.message.status==0) {
				$.alert(s.message.msg, "提示");
				setTimeout(function() {
					$("#n_"+refid).val(""); 
				}, 2000)
			}
		});
	}
function upimg(obj,id){
	var images = {
		localId: [],
		serverId: []
	};
	wx.chooseImage({
		count: 1,
		sourceType: ['album', 'camera'],
		success:function(res){
		images.localId = res.localIds;
		var i = 0, length = images.localId.length;
		var wxUpload = function() {
			wx.uploadImage({
				localId: images.localId[i],
				isShowProgressTips: 1,
				success: function (res) {
					i++;
					images.serverId.push(res.serverId);
					var url = "{php echo $this->createMobileUrl('uploads',array('type'=>'image'));}&serverId=" + res.serverId + "&localId=" + i;
					$.post(url, function(dat){
						var dat = eval("("+dat+")");
							if (dat.status == 'success') {
								$.toast(dat.message, "success");
								$('input[name="'+obj.getAttribute("data")+'"]').val(tomedia(dat.path));
								document.getElementById('show'+id).src = tomedia(dat.path);
							}else{
								$.toast(dat.message, "cancel");
								document.getElementById('show'+id).src = "";
							}
					});
					if(i < length){
						wxUpload();
					}
				},
				fail: function (res) {
					alert(JSON.stringify(res));
				}
			});						
		};
		wxUpload();
		}
	});
}
function show(obj,id){
	var pic=document.getElementById(id).src;
	wx.previewImage({
		current: pic,
		urls: [pic]
		
	});
}
	function fetchgetjs(obj) {
		$('#linkage2').empty();
		$('#linkage2').append('<option value="">请选择</option>');
		if (!$(obj).val()) {
			return false;
		}

		$.getJSON('{php echo $this->createMobileUrl('GetLinkage')}', {'linkage1' : $(obj).val()}, function(s){
			if (s.message.status == 0) {
				$.toast(s.message.jss, 'cancel');
				return false;
			}
			$('#linkage2').empty();
			if (s.message.jss) {
				for (i in s.message.jss) {
					$('#linkage2').append('<option value="'+s.message.jss[i].id+'">'+s.message.jss[i].title+'</option>');
				}
			} 
		});
	}
	$('#form').submit(function(){
       var member = /^[\u4E00-\u9FA5]{1,6}$/;
			if($.trim($(':input[name="member"]').val())=='' || !member.test($.trim($('input[name="member"]').val()))){
				$.toast("请正确输入姓名", "cancel");
				return false;
			}
       var mobile = /^(((13[0-9]{1})|(14[7-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
			if($.trim($(':input[name="mobile"]').val())=='' || !mobile.test($.trim($('input[name="mobile"]').val()))){
				$.toast("请输入正确的手机号码", "cancel");
				return false;
			}
		{if $activity['smsid']!=0}
		var htel=$("#htel").val();
		var hsms=$("#hsms").val();
		var tel=$("#mobile").val();
		var sms=$("#sms").val();
		if(htel==tel){
			if(hsms==sms){
			}else{
				$.toast("请输入正确验证码", "cancel");
				return false;
			}
		}else{
			$.toast("请获取验证码", "cancel");
			return false;
		}
		{/if}
		{if !empty($activity['agreement'])}
		if (document.getElementById("agreement").checked == false){
			$.toast("请仔细阅读并同意{$activity['agreement']}", "cancel");
			document.getElementById("agreement").focus();
			return false;
		}
		{/if}
		{if $ycredit < "0"}
			$.toast("{$creditnames[$behavior['activity']]['title']}不足{$activity['credit']},不能提交", "cancel");
			return false;
		{/if}
		{loop $ds $fields}
		{if $fields['essential']}
		{if in_array($fields['type'], array('text', 'calendar', 'email', 'radio', 'checkbox', 'select', 'range'))}
		if($.trim($(':text[name="field_{$fields['refid']}_{$fields['bind']}"]').val()) == '') {
			$.toast("{$fields['title']} 不能为空", "cancel");
			return false;
		}
		{/if}
		{if in_array($fields['type'], array('radio'))}
		if($.trim($(':input[name="field_{$fields['refid']}_{$fields['bind']}"]').val()) == '') {
			$.toast("{$fields['title']} 不能为空", "cancel");
			return false;
		}
		{/if}
		{if in_array($fields['type'], array('image'))}
		if($.trim($(':input[name="field_{$fields['refid']}_{$fields['bind']}"]').val()) == '') {
			$.toast("{$fields['title']} 必须上传", "cancel");
			return false;
		}
		{/if}
		{if in_array($fields['type'], array('textarea'))}
		if($.trim($('textarea[name="field_{$fields['refid']}_{$fields['bind']}"]').val()) == '') {
			$.toast("{$fields['title']} 必须填写", "cancel");
			return false;
		}
		{/if}
		{if in_array($fields['type'], array('number'))}
		var num = parseFloat($.trim($(':input[name="field_{$fields['refid']}_{$fields['bind']}"]').val()));
		if(isNaN(num)) {
			$.toast('{$fields['title']} 必须输入数字.');
			return false;
		}
		{/if}
		{if in_array($fields['type'], array('email'))}
		var mail = $.trim($(':text[name="field_{$fields['refid']}_{$fields['bind']}"]').val());
		if(!(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/i).test(mail)) {
			$.toast("{$fields['title']} 请正确邮箱地址", "cancel");
			return false;
		}
		{/if}
		{/if}
		{/loop}
		{if $activity['isvoice']==1 && $activity['ivoice']==1}
			if($.trim($(':hidden[name="voice"]').val()) == '') {
				$.toast("请上传{$activity['voice']}", "cancel");
				return false;
			}
		{/if}
		return true;
	});

</script>
{template 'footers'}